package com.link2room.soundwave;

import com.link2room.common.constant.MnsConstant;
import com.link2room.common.mns.Worker;
import com.link2room.common.mns.listener.MnsListener;
import com.link2room.soundwave.constant.SoundwaveMnsConstant;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

/**
 * 加载mns消息服务轮询服务
 * Created by LN on 2016/8/25.
 */
@Component  //使用时，打开注释
public class SoundwaveMNSPollingStartupRunner implements CommandLineRunner {


    @Resource //需要实现此接口
    private Worker pmsSoundwaveReservationRunner;

    @Resource //需要实现此接口
    private Worker pmsReservationStaRunner;

    @Resource //需要实现此接口
    private Worker pmsRoomAvailRunner;

    @Resource //需要实现此接口
    private Worker pmsRateRunner;
    @Resource
    private Worker pmsRateIncrementRunner;

    @Resource
    private MnsListener defaultMnsListener;
    @Override
    public void run(String... strings) throws Exception {
        defaultMnsListener.startPolling(SoundwaveMnsConstant.QUEUE_ORDER_SOUNDWAVE,pmsSoundwaveReservationRunner);
        defaultMnsListener.startPolling(SoundwaveMnsConstant.QUEUE_PMSROOMAVAIL,pmsRoomAvailRunner,5);
        defaultMnsListener.startPolling(SoundwaveMnsConstant.QUEUE_PMSRATE,pmsRateRunner,5);
        defaultMnsListener.startPolling(SoundwaveMnsConstant.QUEUE_PMSRATE_INCREMENT,pmsRateIncrementRunner,5);
        defaultMnsListener.startPolling(SoundwaveMnsConstant.QUEUE_PMSRESSTA,pmsReservationStaRunner,5);
    }
}
